﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using IPC.Communication.Framework;
using IPC.Communication.Framework.Core;
using IPC.Communication.Framework.Enthernet.Redis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace IPC.Communication.Framework.Reflection
{
    public class HslReflectionHelper
    {
	    public static OperateResult<T> Read<T>(IReadWriteNet readWrite) where T : class, new()
	    {
		    Type typeFromHandle = typeof(T);
		    object obj = typeFromHandle.Assembly.CreateInstance(typeFromHandle.FullName);
		    PropertyInfo[] properties = typeFromHandle.GetProperties(BindingFlags.Instance | BindingFlags.Public);
		    PropertyInfo[] array = properties;
		    foreach (PropertyInfo propertyInfo in array)
		    {
			    object[] customAttributes = propertyInfo.GetCustomAttributes(typeof(HslDeviceAddressAttribute), inherit: false);
			    if (customAttributes == null)
			    {
				    continue;
			    }
			    HslDeviceAddressAttribute hslDeviceAddressAttribute = null;
			    for (int j = 0; j < customAttributes.Length; j++)
			    {
				    HslDeviceAddressAttribute hslDeviceAddressAttribute2 = (HslDeviceAddressAttribute)customAttributes[j];
				    if (hslDeviceAddressAttribute2.DeviceType != null && hslDeviceAddressAttribute2.DeviceType == readWrite.GetType())
				    {
					    hslDeviceAddressAttribute = hslDeviceAddressAttribute2;
					    break;
				    }
			    }
			    if (hslDeviceAddressAttribute == null)
			    {
				    for (int k = 0; k < customAttributes.Length; k++)
				    {
					    HslDeviceAddressAttribute hslDeviceAddressAttribute3 = (HslDeviceAddressAttribute)customAttributes[k];
					    if (hslDeviceAddressAttribute3.DeviceType == null)
					    {
						    hslDeviceAddressAttribute = hslDeviceAddressAttribute3;
						    break;
					    }
				    }
			    }
			    if (hslDeviceAddressAttribute == null)
			    {
				    continue;
			    }
			    Type propertyType = propertyInfo.PropertyType;
			    if (propertyType == typeof(short))
			    {
				    OperateResult<short> operateResult = readWrite.ReadInt16(hslDeviceAddressAttribute.Address);
				    if (!operateResult.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult);
				    }
				    propertyInfo.SetValue(obj, operateResult.Content, null);
			    }
			    else if (propertyType == typeof(short[]))
			    {
				    OperateResult<short[]> operateResult2 = readWrite.ReadInt16(hslDeviceAddressAttribute.Address, (ushort)((hslDeviceAddressAttribute.Length <= 0) ? 1 : hslDeviceAddressAttribute.Length));
				    if (!operateResult2.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult2);
				    }
				    propertyInfo.SetValue(obj, operateResult2.Content, null);
			    }
			    else if (propertyType == typeof(ushort))
			    {
				    OperateResult<ushort> operateResult3 = readWrite.ReadUInt16(hslDeviceAddressAttribute.Address);
				    if (!operateResult3.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult3);
				    }
				    propertyInfo.SetValue(obj, operateResult3.Content, null);
			    }
			    else if (propertyType == typeof(ushort[]))
			    {
				    OperateResult<ushort[]> operateResult4 = readWrite.ReadUInt16(hslDeviceAddressAttribute.Address, (ushort)((hslDeviceAddressAttribute.Length <= 0) ? 1 : hslDeviceAddressAttribute.Length));
				    if (!operateResult4.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult4);
				    }
				    propertyInfo.SetValue(obj, operateResult4.Content, null);
			    }
			    else if (propertyType == typeof(int))
			    {
				    OperateResult<int> operateResult5 = readWrite.ReadInt32(hslDeviceAddressAttribute.Address);
				    if (!operateResult5.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult5);
				    }
				    propertyInfo.SetValue(obj, operateResult5.Content, null);
			    }
			    else if (propertyType == typeof(int[]))
			    {
				    OperateResult<int[]> operateResult6 = readWrite.ReadInt32(hslDeviceAddressAttribute.Address, (ushort)((hslDeviceAddressAttribute.Length <= 0) ? 1 : hslDeviceAddressAttribute.Length));
				    if (!operateResult6.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult6);
				    }
				    propertyInfo.SetValue(obj, operateResult6.Content, null);
			    }
			    else if (propertyType == typeof(uint))
			    {
				    OperateResult<uint> operateResult7 = readWrite.ReadUInt32(hslDeviceAddressAttribute.Address);
				    if (!operateResult7.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult7);
				    }
				    propertyInfo.SetValue(obj, operateResult7.Content, null);
			    }
			    else if (propertyType == typeof(uint[]))
			    {
				    OperateResult<uint[]> operateResult8 = readWrite.ReadUInt32(hslDeviceAddressAttribute.Address, (ushort)((hslDeviceAddressAttribute.Length <= 0) ? 1 : hslDeviceAddressAttribute.Length));
				    if (!operateResult8.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult8);
				    }
				    propertyInfo.SetValue(obj, operateResult8.Content, null);
			    }
			    else if (propertyType == typeof(long))
			    {
				    OperateResult<long> operateResult9 = readWrite.ReadInt64(hslDeviceAddressAttribute.Address);
				    if (!operateResult9.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult9);
				    }
				    propertyInfo.SetValue(obj, operateResult9.Content, null);
			    }
			    else if (propertyType == typeof(long[]))
			    {
				    OperateResult<long[]> operateResult10 = readWrite.ReadInt64(hslDeviceAddressAttribute.Address, (ushort)((hslDeviceAddressAttribute.Length <= 0) ? 1 : hslDeviceAddressAttribute.Length));
				    if (!operateResult10.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult10);
				    }
				    propertyInfo.SetValue(obj, operateResult10.Content, null);
			    }
			    else if (propertyType == typeof(ulong))
			    {
				    OperateResult<ulong> operateResult11 = readWrite.ReadUInt64(hslDeviceAddressAttribute.Address);
				    if (!operateResult11.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult11);
				    }
				    propertyInfo.SetValue(obj, operateResult11.Content, null);
			    }
			    else if (propertyType == typeof(ulong[]))
			    {
				    OperateResult<ulong[]> operateResult12 = readWrite.ReadUInt64(hslDeviceAddressAttribute.Address, (ushort)((hslDeviceAddressAttribute.Length <= 0) ? 1 : hslDeviceAddressAttribute.Length));
				    if (!operateResult12.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult12);
				    }
				    propertyInfo.SetValue(obj, operateResult12.Content, null);
			    }
			    else if (propertyType == typeof(float))
			    {
				    OperateResult<float> operateResult13 = readWrite.ReadFloat(hslDeviceAddressAttribute.Address);
				    if (!operateResult13.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult13);
				    }
				    propertyInfo.SetValue(obj, operateResult13.Content, null);
			    }
			    else if (propertyType == typeof(float[]))
			    {
				    OperateResult<float[]> operateResult14 = readWrite.ReadFloat(hslDeviceAddressAttribute.Address, (ushort)((hslDeviceAddressAttribute.Length <= 0) ? 1 : hslDeviceAddressAttribute.Length));
				    if (!operateResult14.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult14);
				    }
				    propertyInfo.SetValue(obj, operateResult14.Content, null);
			    }
			    else if (propertyType == typeof(double))
			    {
				    OperateResult<double> operateResult15 = readWrite.ReadDouble(hslDeviceAddressAttribute.Address);
				    if (!operateResult15.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult15);
				    }
				    propertyInfo.SetValue(obj, operateResult15.Content, null);
			    }
			    else if (propertyType == typeof(double[]))
			    {
				    OperateResult<double[]> operateResult16 = readWrite.ReadDouble(hslDeviceAddressAttribute.Address, (ushort)((hslDeviceAddressAttribute.Length <= 0) ? 1 : hslDeviceAddressAttribute.Length));
				    if (!operateResult16.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult16);
				    }
				    propertyInfo.SetValue(obj, operateResult16.Content, null);
			    }
			    else if (propertyType == typeof(string))
			    {
				    OperateResult<string> operateResult17 = readWrite.ReadString(hslDeviceAddressAttribute.Address, (ushort)((hslDeviceAddressAttribute.Length <= 0) ? 1 : hslDeviceAddressAttribute.Length));
				    if (!operateResult17.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult17);
				    }
				    propertyInfo.SetValue(obj, operateResult17.Content, null);
			    }
			    else if (propertyType == typeof(byte[]))
			    {
				    OperateResult<byte[]> operateResult18 = readWrite.Read(hslDeviceAddressAttribute.Address, (ushort)((hslDeviceAddressAttribute.Length <= 0) ? 1 : hslDeviceAddressAttribute.Length));
				    if (!operateResult18.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult18);
				    }
				    propertyInfo.SetValue(obj, operateResult18.Content, null);
			    }
			    else if (propertyType == typeof(bool))
			    {
				    OperateResult<bool> operateResult19 = readWrite.ReadBool(hslDeviceAddressAttribute.Address);
				    if (!operateResult19.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult19);
				    }
				    propertyInfo.SetValue(obj, operateResult19.Content, null);
			    }
			    else if (propertyType == typeof(bool[]))
			    {
				    OperateResult<bool[]> operateResult20 = readWrite.ReadBool(hslDeviceAddressAttribute.Address, (ushort)((hslDeviceAddressAttribute.Length <= 0) ? 1 : hslDeviceAddressAttribute.Length));
				    if (!operateResult20.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult20);
				    }
				    propertyInfo.SetValue(obj, operateResult20.Content, null);
			    }
		    }
		    return OperateResult.CreateSuccessResult((T)obj);
	    }

	    public static OperateResult Write<T>(T data, IReadWriteNet readWrite) where T : class, new()
	    {
		    if (data == null)
		    {
			    throw new ArgumentNullException("data");
		    }
		    Type typeFromHandle = typeof(T);
		    PropertyInfo[] properties = typeFromHandle.GetProperties(BindingFlags.Instance | BindingFlags.Public);
		    PropertyInfo[] array = properties;
		    foreach (PropertyInfo propertyInfo in array)
		    {
			    object[] customAttributes = propertyInfo.GetCustomAttributes(typeof(HslDeviceAddressAttribute), inherit: false);
			    if (customAttributes == null)
			    {
				    continue;
			    }
			    HslDeviceAddressAttribute hslDeviceAddressAttribute = null;
			    for (int j = 0; j < customAttributes.Length; j++)
			    {
				    HslDeviceAddressAttribute hslDeviceAddressAttribute2 = (HslDeviceAddressAttribute)customAttributes[j];
				    if (hslDeviceAddressAttribute2.DeviceType != null && hslDeviceAddressAttribute2.DeviceType == readWrite.GetType())
				    {
					    hslDeviceAddressAttribute = hslDeviceAddressAttribute2;
					    break;
				    }
			    }
			    if (hslDeviceAddressAttribute == null)
			    {
				    for (int k = 0; k < customAttributes.Length; k++)
				    {
					    HslDeviceAddressAttribute hslDeviceAddressAttribute3 = (HslDeviceAddressAttribute)customAttributes[k];
					    if (hslDeviceAddressAttribute3.DeviceType == null)
					    {
						    hslDeviceAddressAttribute = hslDeviceAddressAttribute3;
						    break;
					    }
				    }
			    }
			    if (hslDeviceAddressAttribute == null)
			    {
				    continue;
			    }
			    Type propertyType = propertyInfo.PropertyType;
			    if (propertyType == typeof(short))
			    {
				    short value = (short)propertyInfo.GetValue(data, null);
				    OperateResult operateResult = readWrite.Write(hslDeviceAddressAttribute.Address, value);
				    if (!operateResult.IsSuccess)
				    {
					    return operateResult;
				    }
			    }
			    else if (propertyType == typeof(short[]))
			    {
				    short[] values = (short[])propertyInfo.GetValue(data, null);
				    OperateResult operateResult2 = readWrite.Write(hslDeviceAddressAttribute.Address, values);
				    if (!operateResult2.IsSuccess)
				    {
					    return operateResult2;
				    }
			    }
			    else if (propertyType == typeof(ushort))
			    {
				    ushort value2 = (ushort)propertyInfo.GetValue(data, null);
				    OperateResult operateResult3 = readWrite.Write(hslDeviceAddressAttribute.Address, value2);
				    if (!operateResult3.IsSuccess)
				    {
					    return operateResult3;
				    }
			    }
			    else if (propertyType == typeof(ushort[]))
			    {
				    ushort[] values2 = (ushort[])propertyInfo.GetValue(data, null);
				    OperateResult operateResult4 = readWrite.Write(hslDeviceAddressAttribute.Address, values2);
				    if (!operateResult4.IsSuccess)
				    {
					    return operateResult4;
				    }
			    }
			    else if (propertyType == typeof(int))
			    {
				    int value3 = (int)propertyInfo.GetValue(data, null);
				    OperateResult operateResult5 = readWrite.Write(hslDeviceAddressAttribute.Address, value3);
				    if (!operateResult5.IsSuccess)
				    {
					    return operateResult5;
				    }
			    }
			    else if (propertyType == typeof(int[]))
			    {
				    int[] values3 = (int[])propertyInfo.GetValue(data, null);
				    OperateResult operateResult6 = readWrite.Write(hslDeviceAddressAttribute.Address, values3);
				    if (!operateResult6.IsSuccess)
				    {
					    return operateResult6;
				    }
			    }
			    else if (propertyType == typeof(uint))
			    {
				    uint value4 = (uint)propertyInfo.GetValue(data, null);
				    OperateResult operateResult7 = readWrite.Write(hslDeviceAddressAttribute.Address, value4);
				    if (!operateResult7.IsSuccess)
				    {
					    return operateResult7;
				    }
			    }
			    else if (propertyType == typeof(uint[]))
			    {
				    uint[] values4 = (uint[])propertyInfo.GetValue(data, null);
				    OperateResult operateResult8 = readWrite.Write(hslDeviceAddressAttribute.Address, values4);
				    if (!operateResult8.IsSuccess)
				    {
					    return operateResult8;
				    }
			    }
			    else if (propertyType == typeof(long))
			    {
				    long value5 = (long)propertyInfo.GetValue(data, null);
				    OperateResult operateResult9 = readWrite.Write(hslDeviceAddressAttribute.Address, value5);
				    if (!operateResult9.IsSuccess)
				    {
					    return operateResult9;
				    }
			    }
			    else if (propertyType == typeof(long[]))
			    {
				    long[] values5 = (long[])propertyInfo.GetValue(data, null);
				    OperateResult operateResult10 = readWrite.Write(hslDeviceAddressAttribute.Address, values5);
				    if (!operateResult10.IsSuccess)
				    {
					    return operateResult10;
				    }
			    }
			    else if (propertyType == typeof(ulong))
			    {
				    ulong value6 = (ulong)propertyInfo.GetValue(data, null);
				    OperateResult operateResult11 = readWrite.Write(hslDeviceAddressAttribute.Address, value6);
				    if (!operateResult11.IsSuccess)
				    {
					    return operateResult11;
				    }
			    }
			    else if (propertyType == typeof(ulong[]))
			    {
				    ulong[] values6 = (ulong[])propertyInfo.GetValue(data, null);
				    OperateResult operateResult12 = readWrite.Write(hslDeviceAddressAttribute.Address, values6);
				    if (!operateResult12.IsSuccess)
				    {
					    return operateResult12;
				    }
			    }
			    else if (propertyType == typeof(float))
			    {
				    float value7 = (float)propertyInfo.GetValue(data, null);
				    OperateResult operateResult13 = readWrite.Write(hslDeviceAddressAttribute.Address, value7);
				    if (!operateResult13.IsSuccess)
				    {
					    return operateResult13;
				    }
			    }
			    else if (propertyType == typeof(float[]))
			    {
				    float[] values7 = (float[])propertyInfo.GetValue(data, null);
				    OperateResult operateResult14 = readWrite.Write(hslDeviceAddressAttribute.Address, values7);
				    if (!operateResult14.IsSuccess)
				    {
					    return operateResult14;
				    }
			    }
			    else if (propertyType == typeof(double))
			    {
				    double value8 = (double)propertyInfo.GetValue(data, null);
				    OperateResult operateResult15 = readWrite.Write(hslDeviceAddressAttribute.Address, value8);
				    if (!operateResult15.IsSuccess)
				    {
					    return operateResult15;
				    }
			    }
			    else if (propertyType == typeof(double[]))
			    {
				    double[] values8 = (double[])propertyInfo.GetValue(data, null);
				    OperateResult operateResult16 = readWrite.Write(hslDeviceAddressAttribute.Address, values8);
				    if (!operateResult16.IsSuccess)
				    {
					    return operateResult16;
				    }
			    }
			    else if (propertyType == typeof(string))
			    {
				    string value9 = (string)propertyInfo.GetValue(data, null);
				    OperateResult operateResult17 = readWrite.Write(hslDeviceAddressAttribute.Address, value9);
				    if (!operateResult17.IsSuccess)
				    {
					    return operateResult17;
				    }
			    }
			    else if (propertyType == typeof(byte[]))
			    {
				    byte[] value10 = (byte[])propertyInfo.GetValue(data, null);
				    OperateResult operateResult18 = readWrite.Write(hslDeviceAddressAttribute.Address, value10);
				    if (!operateResult18.IsSuccess)
				    {
					    return operateResult18;
				    }
			    }
			    else if (propertyType == typeof(bool))
			    {
				    bool value11 = (bool)propertyInfo.GetValue(data, null);
				    OperateResult operateResult19 = readWrite.Write(hslDeviceAddressAttribute.Address, value11);
				    if (!operateResult19.IsSuccess)
				    {
					    return operateResult19;
				    }
			    }
			    else if (propertyType == typeof(bool[]))
			    {
				    bool[] value12 = (bool[])propertyInfo.GetValue(data, null);
				    OperateResult operateResult20 = readWrite.Write(hslDeviceAddressAttribute.Address, value12);
				    if (!operateResult20.IsSuccess)
				    {
					    return operateResult20;
				    }
			    }
		    }
		    return OperateResult.CreateSuccessResult(data);
	    }

	    public static void SetPropertyExp<T, K>(PropertyInfo propertyInfo, T obj, K objValue)
	    {
		    ParameterExpression parameterExpression = Expression.Parameter(typeof(T), "obj");
		    ParameterExpression parameterExpression2 = Expression.Parameter(propertyInfo.PropertyType, "objValue");
		    MethodCallExpression body = Expression.Call(parameterExpression, propertyInfo.GetSetMethod(), parameterExpression2);
		    Expression<Action<T, K>> expression = Expression.Lambda<Action<T, K>>(body, new ParameterExpression[2]
		    {
			    parameterExpression,
			    parameterExpression2
		    });
		    expression.Compile()(obj, objValue);
	    }

        //[AsyncStateMachine(typeof(<ReadAsync>d__3<>))]
        //[DebuggerStepThrough]
        //public static Task<OperateResult<T>> ReadAsync<T>(IReadWriteNet readWrite) where T : class, new()
        //{
        //    <ReadAsync>d__3<T> stateMachine = new <ReadAsync>d__3<T>();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<T>>.Create();
        //    stateMachine.readWrite = readWrite;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__4<>))]
        //[DebuggerStepThrough]
        //public static Task<OperateResult> WriteAsync<T>(T data, IReadWriteNet readWrite) where T : class, new()
        //{
        //    <WriteAsync>d__4<T> stateMachine = new <WriteAsync>d__4<T>();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.data = data;
        //    stateMachine.readWrite = readWrite;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

	    internal static void SetPropertyObjectValue(PropertyInfo property, object obj, string value)
	    {
		    Type propertyType = property.PropertyType;
		    if (propertyType == typeof(short))
		    {
			    property.SetValue(obj, short.Parse(value), null);
		    }
		    else if (propertyType == typeof(ushort))
		    {
			    property.SetValue(obj, ushort.Parse(value), null);
		    }
		    else if (propertyType == typeof(int))
		    {
			    property.SetValue(obj, int.Parse(value), null);
		    }
		    else if (propertyType == typeof(uint))
		    {
			    property.SetValue(obj, uint.Parse(value), null);
		    }
		    else if (propertyType == typeof(long))
		    {
			    property.SetValue(obj, long.Parse(value), null);
		    }
		    else if (propertyType == typeof(ulong))
		    {
			    property.SetValue(obj, ulong.Parse(value), null);
		    }
		    else if (propertyType == typeof(float))
		    {
			    property.SetValue(obj, float.Parse(value), null);
		    }
		    else if (propertyType == typeof(double))
		    {
			    property.SetValue(obj, double.Parse(value), null);
		    }
		    else if (propertyType == typeof(string))
		    {
			    property.SetValue(obj, value, null);
		    }
		    else if (propertyType == typeof(byte))
		    {
			    property.SetValue(obj, byte.Parse(value), null);
		    }
		    else if (propertyType == typeof(bool))
		    {
			    property.SetValue(obj, bool.Parse(value), null);
		    }
		    else
		    {
			    property.SetValue(obj, value, null);
		    }
	    }

	    internal static void SetPropertyObjectValueArray(PropertyInfo property, object obj, string[] values)
	    {
		    Type propertyType = property.PropertyType;
		    if (propertyType == typeof(short[]))
		    {
			    property.SetValue(obj, values.Select((string m) => short.Parse(m)).ToArray(), null);
		    }
		    else if (propertyType == typeof(List<short>))
		    {
			    property.SetValue(obj, values.Select((string m) => short.Parse(m)).ToList(), null);
		    }
		    else if (propertyType == typeof(ushort[]))
		    {
			    property.SetValue(obj, values.Select((string m) => ushort.Parse(m)).ToArray(), null);
		    }
		    else if (propertyType == typeof(List<ushort>))
		    {
			    property.SetValue(obj, values.Select((string m) => ushort.Parse(m)).ToList(), null);
		    }
		    else if (propertyType == typeof(int[]))
		    {
			    property.SetValue(obj, values.Select((string m) => int.Parse(m)).ToArray(), null);
		    }
		    else if (propertyType == typeof(List<int>))
		    {
			    property.SetValue(obj, values.Select((string m) => int.Parse(m)).ToList(), null);
		    }
		    else if (propertyType == typeof(uint[]))
		    {
			    property.SetValue(obj, values.Select((string m) => uint.Parse(m)).ToArray(), null);
		    }
		    else if (propertyType == typeof(List<uint>))
		    {
			    property.SetValue(obj, values.Select((string m) => uint.Parse(m)).ToList(), null);
		    }
		    else if (propertyType == typeof(long[]))
		    {
			    property.SetValue(obj, values.Select((string m) => long.Parse(m)).ToArray(), null);
		    }
		    else if (propertyType == typeof(List<long>))
		    {
			    property.SetValue(obj, values.Select((string m) => long.Parse(m)).ToList(), null);
		    }
		    else if (propertyType == typeof(ulong[]))
		    {
			    property.SetValue(obj, values.Select((string m) => ulong.Parse(m)).ToArray(), null);
		    }
		    else if (propertyType == typeof(List<ulong>))
		    {
			    property.SetValue(obj, values.Select((string m) => ulong.Parse(m)).ToList(), null);
		    }
		    else if (propertyType == typeof(float[]))
		    {
			    property.SetValue(obj, values.Select((string m) => float.Parse(m)).ToArray(), null);
		    }
		    else if (propertyType == typeof(List<float>))
		    {
			    property.SetValue(obj, values.Select((string m) => float.Parse(m)).ToList(), null);
		    }
		    else if (propertyType == typeof(double[]))
		    {
			    property.SetValue(obj, values.Select((string m) => double.Parse(m)).ToArray(), null);
		    }
		    else if (propertyType == typeof(double[]))
		    {
			    property.SetValue(obj, values.Select((string m) => double.Parse(m)).ToList(), null);
		    }
		    else if (propertyType == typeof(string[]))
		    {
			    property.SetValue(obj, values, null);
		    }
		    else if (propertyType == typeof(List<string>))
		    {
			    property.SetValue(obj, new List<string>(values), null);
		    }
		    else if (propertyType == typeof(byte[]))
		    {
			    property.SetValue(obj, values.Select((string m) => byte.Parse(m)).ToArray(), null);
		    }
		    else if (propertyType == typeof(List<byte>))
		    {
			    property.SetValue(obj, values.Select((string m) => byte.Parse(m)).ToList(), null);
		    }
		    else if (propertyType == typeof(bool[]))
		    {
			    property.SetValue(obj, values.Select((string m) => bool.Parse(m)).ToArray(), null);
		    }
		    else if (propertyType == typeof(List<bool>))
		    {
			    property.SetValue(obj, values.Select((string m) => bool.Parse(m)).ToList(), null);
		    }
		    else
		    {
			    property.SetValue(obj, values, null);
		    }
	    }

	    public static OperateResult<T> Read<T>(RedisClient redis) where T : class, new()
	    {
		    Type typeFromHandle = typeof(T);
		    object obj = typeFromHandle.Assembly.CreateInstance(typeFromHandle.FullName);
		    PropertyInfo[] properties = typeFromHandle.GetProperties(BindingFlags.Instance | BindingFlags.Public);
		    List<PropertyInfoKeyName> list = new List<PropertyInfoKeyName>();
		    List<PropertyInfoHashKeyName> list2 = new List<PropertyInfoHashKeyName>();
		    PropertyInfo[] array = properties;
		    foreach (PropertyInfo propertyInfo in array)
		    {
			    object[] customAttributes = propertyInfo.GetCustomAttributes(typeof(HslRedisKeyAttribute), inherit: false);
			    if (customAttributes != null && customAttributes.Length != 0)
			    {
				    HslRedisKeyAttribute hslRedisKeyAttribute = (HslRedisKeyAttribute)customAttributes[0];
				    list.Add(new PropertyInfoKeyName(propertyInfo, hslRedisKeyAttribute.KeyName));
				    continue;
			    }
			    customAttributes = propertyInfo.GetCustomAttributes(typeof(HslRedisListItemAttribute), inherit: false);
			    if (customAttributes != null && customAttributes.Length != 0)
			    {
				    HslRedisListItemAttribute hslRedisListItemAttribute = (HslRedisListItemAttribute)customAttributes[0];
				    OperateResult<string> operateResult = redis.ReadListByIndex(hslRedisListItemAttribute.ListKey, hslRedisListItemAttribute.Index);
				    if (!operateResult.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult);
				    }
				    SetPropertyObjectValue(propertyInfo, obj, operateResult.Content);
				    continue;
			    }
			    customAttributes = propertyInfo.GetCustomAttributes(typeof(HslRedisListAttribute), inherit: false);
			    if (customAttributes != null && customAttributes.Length != 0)
			    {
				    HslRedisListAttribute hslRedisListAttribute = (HslRedisListAttribute)customAttributes[0];
				    OperateResult<string[]> operateResult2 = redis.ListRange(hslRedisListAttribute.ListKey, hslRedisListAttribute.StartIndex, hslRedisListAttribute.EndIndex);
				    if (!operateResult2.IsSuccess)
				    {
					    return OperateResult.CreateFailedResult<T>(operateResult2);
				    }
				    SetPropertyObjectValueArray(propertyInfo, obj, operateResult2.Content);
			    }
			    else
			    {
				    customAttributes = propertyInfo.GetCustomAttributes(typeof(HslRedisHashFieldAttribute), inherit: false);
				    if (customAttributes != null && customAttributes.Length != 0)
				    {
					    HslRedisHashFieldAttribute hslRedisHashFieldAttribute = (HslRedisHashFieldAttribute)customAttributes[0];
					    list2.Add(new PropertyInfoHashKeyName(propertyInfo, hslRedisHashFieldAttribute.HaskKey, hslRedisHashFieldAttribute.Field));
				    }
			    }
		    }
		    if (list.Count > 0)
		    {
			    OperateResult<string[]> operateResult3 = redis.ReadKey(list.Select((PropertyInfoKeyName m) => m.KeyName).ToArray());
			    if (!operateResult3.IsSuccess)
			    {
				    return OperateResult.CreateFailedResult<T>(operateResult3);
			    }
			    for (int j = 0; j < list.Count; j++)
			    {
				    SetPropertyObjectValue(list[j].PropertyInfo, obj, operateResult3.Content[j]);
			    }
		    }
		    if (list2.Count > 0)
		    {
			    var enumerable = from m in list2
				    group m by m.KeyName into g
				    select new
				    {
					    Key = g.Key,
					    Values = g.ToArray()
				    };
			    foreach (var item in enumerable)
			    {
				    if (item.Values.Length == 1)
				    {
					    OperateResult<string> operateResult4 = redis.ReadHashKey(item.Key, item.Values[0].Field);
					    if (!operateResult4.IsSuccess)
					    {
						    return OperateResult.CreateFailedResult<T>(operateResult4);
					    }
					    SetPropertyObjectValue(item.Values[0].PropertyInfo, obj, operateResult4.Content);
				    }
				    else
				    {
					    OperateResult<string[]> operateResult5 = redis.ReadHashKey(item.Key, item.Values.Select((PropertyInfoHashKeyName m) => m.Field).ToArray());
					    if (!operateResult5.IsSuccess)
					    {
						    return OperateResult.CreateFailedResult<T>(operateResult5);
					    }
					    for (int k = 0; k < item.Values.Length; k++)
					    {
						    SetPropertyObjectValue(item.Values[k].PropertyInfo, obj, operateResult5.Content[k]);
					    }
				    }
			    }
		    }
		    return OperateResult.CreateSuccessResult((T)obj);
	    }

	    public static OperateResult Write<T>(T data, RedisClient redis) where T : class, new()
	    {
		    Type typeFromHandle = typeof(T);
		    PropertyInfo[] properties = typeFromHandle.GetProperties(BindingFlags.Instance | BindingFlags.Public);
		    List<PropertyInfoKeyName> list = new List<PropertyInfoKeyName>();
		    List<PropertyInfoHashKeyName> list2 = new List<PropertyInfoHashKeyName>();
		    PropertyInfo[] array = properties;
		    foreach (PropertyInfo propertyInfo in array)
		    {
			    object[] customAttributes = propertyInfo.GetCustomAttributes(typeof(HslRedisKeyAttribute), inherit: false);
			    if (customAttributes != null && customAttributes.Length != 0)
			    {
				    HslRedisKeyAttribute hslRedisKeyAttribute = (HslRedisKeyAttribute)customAttributes[0];
				    list.Add(new PropertyInfoKeyName(propertyInfo, hslRedisKeyAttribute.KeyName, propertyInfo.GetValue(data, null).ToString()));
				    continue;
			    }
			    customAttributes = propertyInfo.GetCustomAttributes(typeof(HslRedisHashFieldAttribute), inherit: false);
			    if (customAttributes != null && customAttributes.Length != 0)
			    {
				    HslRedisHashFieldAttribute hslRedisHashFieldAttribute = (HslRedisHashFieldAttribute)customAttributes[0];
				    list2.Add(new PropertyInfoHashKeyName(propertyInfo, hslRedisHashFieldAttribute.HaskKey, hslRedisHashFieldAttribute.Field, propertyInfo.GetValue(data, null).ToString()));
			    }
		    }
		    if (list.Count > 0)
		    {
			    OperateResult operateResult = redis.WriteKey(list.Select((PropertyInfoKeyName m) => m.KeyName).ToArray(), list.Select((PropertyInfoKeyName m) => m.Value).ToArray());
			    if (!operateResult.IsSuccess)
			    {
				    return operateResult;
			    }
		    }
		    if (list2.Count > 0)
		    {
			    var enumerable = from m in list2
				    group m by m.KeyName into g
				    select new
				    {
					    Key = g.Key,
					    Values = g.ToArray()
				    };
			    foreach (var item in enumerable)
			    {
				    if (item.Values.Length == 1)
				    {
					    OperateResult operateResult2 = redis.WriteHashKey(item.Key, item.Values[0].Field, item.Values[0].Value);
					    if (!operateResult2.IsSuccess)
					    {
						    return operateResult2;
					    }
				    }
				    else
				    {
					    OperateResult operateResult3 = redis.WriteHashKey(item.Key, item.Values.Select((PropertyInfoHashKeyName m) => m.Field).ToArray(), item.Values.Select((PropertyInfoHashKeyName m) => m.Value).ToArray());
					    if (!operateResult3.IsSuccess)
					    {
						    return operateResult3;
					    }
				    }
			    }
		    }
		    return OperateResult.CreateSuccessResult();
	    }

        //[AsyncStateMachine(typeof(<ReadAsync>d__9<>))]
        //[DebuggerStepThrough]
        //public static Task<OperateResult<T>> ReadAsync<T>(RedisClient redis) where T : class, new()
        //{
        //    <ReadAsync>d__9<T> stateMachine = new <ReadAsync>d__9<T>();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<T>>.Create();
        //    stateMachine.redis = redis;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__10<>))]
        //[DebuggerStepThrough]
        //public static Task<OperateResult> WriteAsync<T>(T data, RedisClient redis) where T : class, new()
        //{
        //    <WriteAsync>d__10<T> stateMachine = new <WriteAsync>d__10<T>();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.data = data;
        //    stateMachine.redis = redis;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

	    public static object[] GetParametersFromJson(ISessionContext context, ParameterInfo[] parameters, string json)
	    {
		    //IL_0011: Unknown result type (might be due to invalid IL or missing references)
		    JObject val = (JObject)(string.IsNullOrEmpty(json) ? ((object)new JObject()) : JObject.Parse(json));
		    object[] array = new object[parameters.Length];
		    for (int i = 0; i < parameters.Length; i++)
		    {
			    if (parameters[i].ParameterType == typeof(byte))
			    {
				    array[i] = ((JToken)val).Value<byte>((object)parameters[i].Name);
			    }
			    else if (parameters[i].ParameterType == typeof(short))
			    {
				    array[i] = ((JToken)val).Value<short>((object)parameters[i].Name);
			    }
			    else if (parameters[i].ParameterType == typeof(ushort))
			    {
				    array[i] = ((JToken)val).Value<ushort>((object)parameters[i].Name);
			    }
			    else if (parameters[i].ParameterType == typeof(int))
			    {
				    array[i] = ((JToken)val).Value<int>((object)parameters[i].Name);
			    }
			    else if (parameters[i].ParameterType == typeof(uint))
			    {
				    array[i] = ((JToken)val).Value<uint>((object)parameters[i].Name);
			    }
			    else if (parameters[i].ParameterType == typeof(long))
			    {
				    array[i] = ((JToken)val).Value<long>((object)parameters[i].Name);
			    }
			    else if (parameters[i].ParameterType == typeof(ulong))
			    {
				    array[i] = ((JToken)val).Value<ulong>((object)parameters[i].Name);
			    }
			    else if (parameters[i].ParameterType == typeof(double))
			    {
				    array[i] = ((JToken)val).Value<double>((object)parameters[i].Name);
			    }
			    else if (parameters[i].ParameterType == typeof(float))
			    {
				    array[i] = ((JToken)val).Value<float>((object)parameters[i].Name);
			    }
			    else if (parameters[i].ParameterType == typeof(bool))
			    {
				    array[i] = ((JToken)val).Value<bool>((object)parameters[i].Name);
			    }
			    else if (parameters[i].ParameterType == typeof(string))
			    {
				    array[i] = ((JToken)val).Value<string>((object)parameters[i].Name);
			    }
			    else if (parameters[i].ParameterType == typeof(DateTime))
			    {
				    array[i] = ((JToken)val).Value<DateTime>((object)parameters[i].Name);
			    }
			    else if (parameters[i].ParameterType == typeof(byte[]))
			    {
				    array[i] = ((JToken)val).Value<string>((object)parameters[i].Name).ToHexBytes();
			    }
			    else if (parameters[i].ParameterType == typeof(short[]))
			    {
				    array[i] = (from m in ((IEnumerable<JToken>)val.GetValue(parameters[i].Name)).ToArray()
					    select Extensions.Value<short>((IEnumerable<JToken>)m)).ToArray();
			    }
			    else if (parameters[i].ParameterType == typeof(ushort[]))
			    {
                    array[i] = (from m in ((IEnumerable<JToken>)val.GetValue(parameters[i].Name)).ToArray()
					    select Extensions.Value<ushort>((IEnumerable<JToken>)m)).ToArray();
			    }
			    else if (parameters[i].ParameterType == typeof(int[]))
			    {
                    array[i] = (from m in ((IEnumerable<JToken>)val.GetValue(parameters[i].Name)).ToArray()
					    select Extensions.Value<int>((IEnumerable<JToken>)m)).ToArray();
			    }
			    else if (parameters[i].ParameterType == typeof(uint[]))
			    {
                    array[i] = (from m in ((IEnumerable<JToken>)val.GetValue(parameters[i].Name)).ToArray()
					    select Extensions.Value<uint>((IEnumerable<JToken>)m)).ToArray();
			    }
			    else if (parameters[i].ParameterType == typeof(long[]))
			    {
                    array[i] = (from m in ((IEnumerable<JToken>)val.GetValue(parameters[i].Name)).ToArray()
					    select Extensions.Value<long>((IEnumerable<JToken>)m)).ToArray();
			    }
			    else if (parameters[i].ParameterType == typeof(ulong[]))
			    {
                    array[i] = (from m in ((IEnumerable<JToken>)val.GetValue(parameters[i].Name)).ToArray()
					    select Extensions.Value<ulong>((IEnumerable<JToken>)m)).ToArray();
			    }
			    else if (parameters[i].ParameterType == typeof(float[]))
			    {
                    array[i] = (from m in ((IEnumerable<JToken>)val.GetValue(parameters[i].Name)).ToArray()
					    select Extensions.Value<float>((IEnumerable<JToken>)m)).ToArray();
			    }
			    else if (parameters[i].ParameterType == typeof(double[]))
			    {
                    array[i] = (from m in ((IEnumerable<JToken>)val.GetValue(parameters[i].Name)).ToArray()
					    select Extensions.Value<double>((IEnumerable<JToken>)m)).ToArray();
			    }
			    else if (parameters[i].ParameterType == typeof(bool[]))
			    {
                    array[i] = (from m in ((IEnumerable<JToken>)val.GetValue(parameters[i].Name)).ToArray()
					    select Extensions.Value<bool>((IEnumerable<JToken>)m)).ToArray();
			    }
			    else if (parameters[i].ParameterType == typeof(string[]))
			    {
                    array[i] = (from m in ((IEnumerable<JToken>)val.GetValue(parameters[i].Name)).ToArray()
					    select Extensions.Value<string>((IEnumerable<JToken>)m)).ToArray();
			    }
			    else if (parameters[i].ParameterType == typeof(DateTime[]))
			    {
                    array[i] = (from m in ((IEnumerable<JToken>)val.GetValue(parameters[i].Name)).ToArray()
					    select Extensions.Value<DateTime>((IEnumerable<JToken>)m)).ToArray();
			    }
			    else if (parameters[i].ParameterType == typeof(ISessionContext))
			    {
				    array[i] = context;
			    }
			    else
			    {
                    array[i] = val.GetValue(parameters[i].Name).ToObject(parameters[i].ParameterType);
			    }
		    }
		    return array;
	    }

	    public static object[] GetParametersFromUrl(ISessionContext context, ParameterInfo[] parameters, string url)
	    {
		    if (url.IndexOf('?') > 0)
		    {
			    url = url.Substring(url.IndexOf('?') + 1);
		    }
		    string[] array = url.Split(new char[1]
		    {
			    '&'
		    }, StringSplitOptions.RemoveEmptyEntries);
		    Dictionary<string, string> dictionary = new Dictionary<string, string>(array.Length);
		    for (int i = 0; i < array.Length; i++)
		    {
			    if (!string.IsNullOrEmpty(array[i]) && array[i].IndexOf('=') > 0)
			    {
				    dictionary.Add(array[i].Substring(0, array[i].IndexOf('=')).Trim(' '), array[i].Substring(array[i].IndexOf('=') + 1));
			    }
		    }
		    object[] array2 = new object[parameters.Length];
		    for (int j = 0; j < parameters.Length; j++)
		    {
			    if (parameters[j].ParameterType == typeof(byte))
			    {
				    array2[j] = byte.Parse(dictionary[parameters[j].Name]);
			    }
			    else if (parameters[j].ParameterType == typeof(short))
			    {
				    array2[j] = short.Parse(dictionary[parameters[j].Name]);
			    }
			    else if (parameters[j].ParameterType == typeof(ushort))
			    {
				    array2[j] = ushort.Parse(dictionary[parameters[j].Name]);
			    }
			    else if (parameters[j].ParameterType == typeof(int))
			    {
				    array2[j] = int.Parse(dictionary[parameters[j].Name]);
			    }
			    else if (parameters[j].ParameterType == typeof(uint))
			    {
				    array2[j] = uint.Parse(dictionary[parameters[j].Name]);
			    }
			    else if (parameters[j].ParameterType == typeof(long))
			    {
				    array2[j] = long.Parse(dictionary[parameters[j].Name]);
			    }
			    else if (parameters[j].ParameterType == typeof(ulong))
			    {
				    array2[j] = ulong.Parse(dictionary[parameters[j].Name]);
			    }
			    else if (parameters[j].ParameterType == typeof(double))
			    {
				    array2[j] = double.Parse(dictionary[parameters[j].Name]);
			    }
			    else if (parameters[j].ParameterType == typeof(float))
			    {
				    array2[j] = float.Parse(dictionary[parameters[j].Name]);
			    }
			    else if (parameters[j].ParameterType == typeof(bool))
			    {
				    array2[j] = bool.Parse(dictionary[parameters[j].Name]);
			    }
			    else if (parameters[j].ParameterType == typeof(string))
			    {
				    array2[j] = dictionary[parameters[j].Name];
			    }
			    else if (parameters[j].ParameterType == typeof(DateTime))
			    {
				    array2[j] = DateTime.Parse(dictionary[parameters[j].Name]);
			    }
			    else if (parameters[j].ParameterType == typeof(byte[]))
			    {
				    array2[j] = dictionary[parameters[j].Name].ToHexBytes();
			    }
			    else if (parameters[j].ParameterType == typeof(short[]))
			    {
				    array2[j] = dictionary[parameters[j].Name].ToStringArray<short>();
			    }
			    else if (parameters[j].ParameterType == typeof(ushort[]))
			    {
				    array2[j] = dictionary[parameters[j].Name].ToStringArray<ushort>();
			    }
			    else if (parameters[j].ParameterType == typeof(int[]))
			    {
				    array2[j] = dictionary[parameters[j].Name].ToStringArray<int>();
			    }
			    else if (parameters[j].ParameterType == typeof(uint[]))
			    {
				    array2[j] = dictionary[parameters[j].Name].ToStringArray<uint>();
			    }
			    else if (parameters[j].ParameterType == typeof(long[]))
			    {
				    array2[j] = dictionary[parameters[j].Name].ToStringArray<long>();
			    }
			    else if (parameters[j].ParameterType == typeof(ulong[]))
			    {
				    array2[j] = dictionary[parameters[j].Name].ToStringArray<ulong>();
			    }
			    else if (parameters[j].ParameterType == typeof(float[]))
			    {
				    array2[j] = dictionary[parameters[j].Name].ToStringArray<float>();
			    }
			    else if (parameters[j].ParameterType == typeof(double[]))
			    {
				    array2[j] = dictionary[parameters[j].Name].ToStringArray<double>();
			    }
			    else if (parameters[j].ParameterType == typeof(bool[]))
			    {
				    array2[j] = dictionary[parameters[j].Name].ToStringArray<bool>();
			    }
			    else if (parameters[j].ParameterType == typeof(string[]))
			    {
				    array2[j] = dictionary[parameters[j].Name].ToStringArray<string>();
			    }
			    else if (parameters[j].ParameterType == typeof(DateTime[]))
			    {
				    array2[j] = dictionary[parameters[j].Name].ToStringArray<DateTime>();
			    }
			    else if (parameters[j].ParameterType == typeof(ISessionContext))
			    {
				    array2[j] = context;
			    }
			    else
			    {
				    array2[j] = JToken.Parse(dictionary[parameters[j].Name]).ToObject(parameters[j].ParameterType);
			    }
		    }
		    return array2;
	    }

	    public static JObject GetParametersFromJson(MethodInfo method, ParameterInfo[] parameters)
	    {
		    //IL_0001: Unknown result type (might be due to invalid IL or missing references)
		    //IL_0007: Expected O, but got Unknown
		    //IL_004e: Unknown result type (might be due to invalid IL or missing references)
		    //IL_0058: Expected O, but got Unknown
		    //IL_009d: Unknown result type (might be due to invalid IL or missing references)
		    //IL_00a7: Expected O, but got Unknown
		    //IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		    //IL_00f8: Expected O, but got Unknown
		    //IL_013f: Unknown result type (might be due to invalid IL or missing references)
		    //IL_0149: Expected O, but got Unknown
		    //IL_0190: Unknown result type (might be due to invalid IL or missing references)
		    //IL_019a: Expected O, but got Unknown
		    //IL_01e1: Unknown result type (might be due to invalid IL or missing references)
		    //IL_01eb: Expected O, but got Unknown
		    //IL_0232: Unknown result type (might be due to invalid IL or missing references)
		    //IL_023c: Expected O, but got Unknown
		    //IL_028a: Unknown result type (might be due to invalid IL or missing references)
		    //IL_0294: Expected O, but got Unknown
		    //IL_02de: Unknown result type (might be due to invalid IL or missing references)
		    //IL_02e8: Expected O, but got Unknown
		    //IL_032e: Unknown result type (might be due to invalid IL or missing references)
		    //IL_0338: Expected O, but got Unknown
		    //IL_0382: Unknown result type (might be due to invalid IL or missing references)
		    //IL_038c: Expected O, but got Unknown
		    //IL_03f2: Unknown result type (might be due to invalid IL or missing references)
		    //IL_03fc: Expected O, but got Unknown
		    //IL_044b: Unknown result type (might be due to invalid IL or missing references)
		    //IL_0455: Expected O, but got Unknown
		    //IL_04ab: Unknown result type (might be due to invalid IL or missing references)
		    //IL_04b5: Expected O, but got Unknown
		    //IL_050b: Unknown result type (might be due to invalid IL or missing references)
		    //IL_0515: Expected O, but got Unknown
		    //IL_056b: Unknown result type (might be due to invalid IL or missing references)
		    //IL_0575: Expected O, but got Unknown
		    //IL_05cb: Unknown result type (might be due to invalid IL or missing references)
		    //IL_05d5: Expected O, but got Unknown
		    //IL_062b: Unknown result type (might be due to invalid IL or missing references)
		    //IL_0635: Expected O, but got Unknown
		    //IL_068b: Unknown result type (might be due to invalid IL or missing references)
		    //IL_0695: Expected O, but got Unknown
		    //IL_06eb: Unknown result type (might be due to invalid IL or missing references)
		    //IL_06f5: Expected O, but got Unknown
		    //IL_074b: Unknown result type (might be due to invalid IL or missing references)
		    //IL_0755: Expected O, but got Unknown
		    //IL_07a4: Unknown result type (might be due to invalid IL or missing references)
		    //IL_07ae: Expected O, but got Unknown
		    //IL_0815: Unknown result type (might be due to invalid IL or missing references)
		    //IL_081f: Expected O, but got Unknown
		    //IL_08ad: Unknown result type (might be due to invalid IL or missing references)
		    //IL_08b7: Expected O, but got Unknown
		    JObject val = (JObject)(object)new JObject();
		    for (int i = 0; i < parameters.Length; i++)
		    {
			    if (parameters[i].ParameterType == typeof(byte))
			    {
				    val.Add(parameters[i].Name, (JToken)(object)new JValue((long)(uint)(parameters[i].DefaultValue != null ? ((byte)parameters[i].DefaultValue) : 0)));
			    }
			    else if (parameters[i].ParameterType == typeof(short))
			    {
				    val.Add(parameters[i].Name, (JToken)(object)new JValue((long)(parameters[i].DefaultValue != null ? ((short)parameters[i].DefaultValue) : 0)));
			    }
			    else if (parameters[i].ParameterType == typeof(ushort))
			    {
				    val.Add(parameters[i].Name, (JToken)(object)new JValue((long)(uint)(parameters[i].DefaultValue != null ? ((ushort)parameters[i].DefaultValue) : 0)));
			    }
			    else if (parameters[i].ParameterType == typeof(int))
			    {
				    val.Add(parameters[i].Name, (JToken)(object)new JValue((long)(parameters[i].DefaultValue != null ? ((int)parameters[i].DefaultValue) : 0)));
			    }
			    else if (parameters[i].ParameterType == typeof(uint))
			    {
				    val.Add(parameters[i].Name, (JToken)(object)new JValue((long)(parameters[i].DefaultValue != null ? ((uint)parameters[i].DefaultValue) : 0)));
			    }
			    else if (parameters[i].ParameterType == typeof(long))
			    {
				    val.Add(parameters[i].Name, (JToken)(object)new JValue(parameters[i].DefaultValue != null ? ((long)parameters[i].DefaultValue) : 0));
			    }
			    else if (parameters[i].ParameterType == typeof(ulong))
			    {
				    val.Add(parameters[i].Name, (JToken)(object)new JValue(parameters[i].DefaultValue != null ? ((ulong)parameters[i].DefaultValue) : 0));
			    }
			    else if (parameters[i].ParameterType == typeof(double))
			    {
				    val.Add(parameters[i].Name, (JToken)(object)new JValue(parameters[i].DefaultValue != null ? ((double)parameters[i].DefaultValue) : 0.0));
			    }
			    else if (parameters[i].ParameterType == typeof(float))
			    {
				    val.Add(parameters[i].Name, (JToken)(object)new JValue(parameters[i].DefaultValue != null ? ((float)parameters[i].DefaultValue) : 0f));
			    }
			    else if (parameters[i].ParameterType == typeof(bool))
			    {
                    val.Add(parameters[i].Name, (JToken)(object)new JValue(parameters[i].DefaultValue != null && (bool)parameters[i].DefaultValue));
			    }
			    else if (parameters[i].ParameterType == typeof(string))
			    {
                    val.Add(parameters[i].Name, (JToken)(object)new JValue(parameters[i].DefaultValue != null ? ((string)parameters[i].DefaultValue) : ""));
			    }
			    else if (parameters[i].ParameterType == typeof(DateTime))
			    {
                    val.Add(parameters[i].Name, (JToken)(object)new JValue(parameters[i].DefaultValue != null ? ((DateTime)parameters[i].DefaultValue).ToString("yyyy-MM-dd HH:mm:ss") : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
			    }
			    else if (parameters[i].ParameterType == typeof(byte[]))
			    {
                    val.Add(parameters[i].Name, (JToken)(object)new JValue(parameters[i].DefaultValue != null ? ((byte[])parameters[i].DefaultValue).ToHexString() : "00 1A 2B 3C 4D"));
			    }
			    else if (parameters[i].ParameterType == typeof(short[]))
			    {
                    val.Add(parameters[i].Name, (JToken)(object)new JArray((object)(parameters[i].DefaultValue != null ? ((short[])parameters[i].DefaultValue) : new short[3]
				    {
					    1,
					    2,
					    3
				    })));
			    }
			    else if (parameters[i].ParameterType == typeof(ushort[]))
			    {
                    val.Add(parameters[i].Name, (JToken)(object)new JArray((object)(parameters[i].DefaultValue != null ? ((ushort[])parameters[i].DefaultValue) : new ushort[3]
				    {
					    1,
					    2,
					    3
				    })));
			    }
			    else if (parameters[i].ParameterType == typeof(int[]))
			    {
                    val.Add(parameters[i].Name, (JToken)(object)new JArray((object)(parameters[i].DefaultValue != null ? ((int[])parameters[i].DefaultValue) : new int[3]
				    {
					    1,
					    2,
					    3
				    })));
			    }
			    else if (parameters[i].ParameterType == typeof(uint[]))
			    {
                    val.Add(parameters[i].Name, (JToken)(object)new JArray((object)(parameters[i].DefaultValue != null ? ((uint[])parameters[i].DefaultValue) : new uint[3]
				    {
					    1u,
					    2u,
					    3u
				    })));
			    }
			    else if (parameters[i].ParameterType == typeof(long[]))
			    {
                    val.Add(parameters[i].Name, (JToken)(object)new JArray((object)(parameters[i].DefaultValue != null ? ((long[])parameters[i].DefaultValue) : new long[3]
				    {
					    1L,
					    2L,
					    3L
				    })));
			    }
			    else if (parameters[i].ParameterType == typeof(ulong[]))
			    {
                    val.Add(parameters[i].Name, (JToken)(object)new JArray((object)(parameters[i].DefaultValue != null ? ((ulong[])parameters[i].DefaultValue) : new ulong[3]
				    {
					    1uL,
					    2uL,
					    3uL
				    })));
			    }
			    else if (parameters[i].ParameterType == typeof(float[]))
			    {
                    val.Add(parameters[i].Name, (JToken)(object)new JArray((object)(parameters[i].DefaultValue != null ? ((float[])parameters[i].DefaultValue) : new float[3]
				    {
					    1f,
					    2f,
					    3f
				    })));
			    }
			    else if (parameters[i].ParameterType == typeof(double[]))
			    {
                    val.Add(parameters[i].Name, (JToken)(object)new JArray((object)(parameters[i].DefaultValue != null ? ((double[])parameters[i].DefaultValue) : new double[3]
				    {
					    1.0,
					    2.0,
					    3.0
				    })));
			    }
			    else if (parameters[i].ParameterType == typeof(bool[]))
			    {
                    val.Add(parameters[i].Name, (JToken)(object)new JArray((object)(parameters[i].DefaultValue != null ? ((bool[])parameters[i].DefaultValue) : new bool[3]
				    {
					    true,
					    false,
					    false
				    })));
			    }
			    else if (parameters[i].ParameterType == typeof(string[]))
			    {
				    string name = parameters[i].Name;
                    object[] array = parameters[i].DefaultValue != null ? ((string[])parameters[i].DefaultValue) : new string[3]
				    {
					    "1",
					    "2",
					    "3"
				    };
				    val.Add(name, (JToken)(object)new JArray(array));
			    }
			    else if (parameters[i].ParameterType == typeof(DateTime[]))
			    {
				    string name2 = parameters[i].Name;
                    object[] array = parameters[i].DefaultValue != null ? ((DateTime[])parameters[i].DefaultValue).Select((DateTime m) => m.ToString("yyyy-MM-dd HH:mm:ss")).ToArray() : new string[1]
				    {
					    DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
				    };
				    val.Add(name2, (JToken)(object)new JArray(array));
			    }
			    else if (!(parameters[i].ParameterType == typeof(ISessionContext)))
			    {
                    val.Add(parameters[i].Name, JToken.FromObject(parameters[i].DefaultValue != null ? parameters[i].DefaultValue : Activator.CreateInstance(parameters[i].ParameterType)));
			    }
		    }
		    return val;
	    }

	    public static OperateResult<string> GetOperateResultJsonFromObj(object obj)
	    {
		    OperateResult operateResult = obj as OperateResult;
		    if (operateResult != null)
		    {
			    OperateResult<string> operateResult2 = new OperateResult<string>();
			    operateResult2.IsSuccess = operateResult.IsSuccess;
			    operateResult2.ErrorCode = operateResult.ErrorCode;
			    operateResult2.Message = operateResult.Message;
			    if (operateResult.IsSuccess)
			    {
				    PropertyInfo property = obj.GetType().GetProperty("Content");
				    if (property != null)
				    {
					    object value = property.GetValue(obj, null);
					    if (value != null)
					    {
						    operateResult2.Content = value.ToJsonString((Formatting)1);
					    }
					    return operateResult2;
				    }
				    PropertyInfo property2 = obj.GetType().GetProperty("Content1");
				    if (property2 == null)
				    {
					    return operateResult2;
				    }
				    PropertyInfo property3 = obj.GetType().GetProperty("Content2");
				    if (property3 == null)
				    {
					    operateResult2.Content = new
					    {
						    Content1 = property2.GetValue(obj, null)
					    }.ToJsonString((Formatting)1);
					    return operateResult2;
				    }
				    PropertyInfo property4 = obj.GetType().GetProperty("Content3");
				    if (property4 == null)
				    {
					    operateResult2.Content = new
					    {
						    Content1 = property2.GetValue(obj, null),
						    Content2 = property3.GetValue(obj, null)
					    }.ToJsonString((Formatting)1);
					    return operateResult2;
				    }
				    PropertyInfo property5 = obj.GetType().GetProperty("Content4");
				    if (property5 == null)
				    {
					    operateResult2.Content = new
					    {
						    Content1 = property2.GetValue(obj, null),
						    Content2 = property3.GetValue(obj, null),
						    Content3 = property4.GetValue(obj, null)
					    }.ToJsonString((Formatting)1);
					    return operateResult2;
				    }
				    PropertyInfo property6 = obj.GetType().GetProperty("Content5");
				    if (property6 == null)
				    {
					    operateResult2.Content = new
					    {
						    Content1 = property2.GetValue(obj, null),
						    Content2 = property3.GetValue(obj, null),
						    Content3 = property4.GetValue(obj, null),
						    Content4 = property5.GetValue(obj, null)
					    }.ToJsonString((Formatting)1);
					    return operateResult2;
				    }
				    PropertyInfo property7 = obj.GetType().GetProperty("Content6");
				    if (property7 == null)
				    {
					    operateResult2.Content = new
					    {
						    Content1 = property2.GetValue(obj, null),
						    Content2 = property3.GetValue(obj, null),
						    Content3 = property4.GetValue(obj, null),
						    Content4 = property5.GetValue(obj, null),
						    Content5 = property6.GetValue(obj, null)
					    }.ToJsonString((Formatting)1);
					    return operateResult2;
				    }
				    PropertyInfo property8 = obj.GetType().GetProperty("Content7");
				    if (property8 == null)
				    {
					    operateResult2.Content = new
					    {
						    Content1 = property2.GetValue(obj, null),
						    Content2 = property3.GetValue(obj, null),
						    Content3 = property4.GetValue(obj, null),
						    Content4 = property5.GetValue(obj, null),
						    Content5 = property6.GetValue(obj, null),
						    Content6 = property7.GetValue(obj, null)
					    }.ToJsonString((Formatting)1);
					    return operateResult2;
				    }
				    PropertyInfo property9 = obj.GetType().GetProperty("Content8");
				    if (property9 == null)
				    {
					    operateResult2.Content = new
					    {
						    Content1 = property2.GetValue(obj, null),
						    Content2 = property3.GetValue(obj, null),
						    Content3 = property4.GetValue(obj, null),
						    Content4 = property5.GetValue(obj, null),
						    Content5 = property6.GetValue(obj, null),
						    Content6 = property7.GetValue(obj, null),
						    Content7 = property8.GetValue(obj, null)
					    }.ToJsonString((Formatting)1);
					    return operateResult2;
				    }
				    PropertyInfo property10 = obj.GetType().GetProperty("Content9");
				    if (property10 == null)
				    {
					    operateResult2.Content = new
					    {
						    Content1 = property2.GetValue(obj, null),
						    Content2 = property3.GetValue(obj, null),
						    Content3 = property4.GetValue(obj, null),
						    Content4 = property5.GetValue(obj, null),
						    Content5 = property6.GetValue(obj, null),
						    Content6 = property7.GetValue(obj, null),
						    Content7 = property8.GetValue(obj, null),
						    Content8 = property9.GetValue(obj, null)
					    }.ToJsonString((Formatting)1);
					    return operateResult2;
				    }
				    PropertyInfo property11 = obj.GetType().GetProperty("Content10");
				    if (property11 == null)
				    {
					    operateResult2.Content = new
					    {
						    Content1 = property2.GetValue(obj, null),
						    Content2 = property3.GetValue(obj, null),
						    Content3 = property4.GetValue(obj, null),
						    Content4 = property5.GetValue(obj, null),
						    Content5 = property6.GetValue(obj, null),
						    Content6 = property7.GetValue(obj, null),
						    Content7 = property8.GetValue(obj, null),
						    Content8 = property9.GetValue(obj, null),
						    Content9 = property10.GetValue(obj, null)
					    }.ToJsonString((Formatting)1);
					    return operateResult2;
				    }
				    operateResult2.Content = new
				    {
					    Content1 = property2.GetValue(obj, null),
					    Content2 = property3.GetValue(obj, null),
					    Content3 = property4.GetValue(obj, null),
					    Content4 = property5.GetValue(obj, null),
					    Content5 = property6.GetValue(obj, null),
					    Content6 = property7.GetValue(obj, null),
					    Content7 = property8.GetValue(obj, null),
					    Content8 = property9.GetValue(obj, null),
					    Content9 = property10.GetValue(obj, null),
					    Content10 = property11.GetValue(obj, null)
				    }.ToJsonString((Formatting)1);
				    return operateResult2;
			    }
			    return operateResult2;
		    }
		    return OperateResult.CreateSuccessResult((obj == null) ? string.Empty : obj.ToJsonString((Formatting)1));
	    }
    }
}
